function load_plugin(plugid) { // 创建插件窗口
    win_create_window(400, 200, "Plugin " + plugid, "<iframe class=\"win_window-iframe\" src=\"/api/plugin/" + plugid + "/iframe/index.html\">Loading...</iframe>")
}
function load_icons() { // 加载图标
    console.log("Loading icons")
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "/api/home/icon", true);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            try {
                var data = JSON.parse(xhr.responseText);
            } catch (error) {
                console.error(error);
                error()
            }

            // 遍历图标列表
            var icons = data["icons"];
            icons.forEach((element) => {
                win_create_icon(element["name"], element["image"], function () { (function (plugid) { load_plugin(plugid) })(element["id"]) })
            });
        } else if (xhr.readyState == 4) {
            console.error("Error loading: " + xhr.status.toString());
            error()
        }
    }
    xhr.send();
}
CHECK_DESKTOP_LOAD = 1
